const path = require('path')
const fs = require('fs')
const glob = require('glob')

const appDirectory = fs.realpathSync(process.cwd())
const resolveApp = relativePath => path.resolve(appDirectory, relativePath)

exports.getEntry = function () {
  const entryList = {}
  const fileList = glob.sync(`${resolveApp('src')}/pages/*/index.js`)
  fileList.forEach(file => {
    let parse_path = path.parse(file);
    let name = parse_path.dir.split('/').slice(-1)[0];
    entryList[name] = {
      appJs: `${parse_path.dir}/${parse_path.base}`,
      appHtml: `public/${name}.html`
    }
  })
  return entryList
}